package com.tsystems.tuni.sportplanet.entity;

import java.io.Serializable;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlTransient;

/**
 * Result Entity.
 * 
 * @author Yuriy Eremin
 * 
 */
@Entity
@Table(name = "result", catalog = "sportsplanet")
public class Result implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ResultId id;
	private Team team;
	private Game game;
	private int score;
	private Byte result;

	public Result() {
	}

	public Result(ResultId id, Team team, Game game, int score) {
		this.id = id;
		this.team = team;
		this.game = game;
		this.score = score;
	}

	public Result(ResultId id, Team team, Game game, int score, Byte result) {
		this.id = id;
		this.team = team;
		this.game = game;
		this.score = score;
		this.result = result;
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "teamTeamId", column = @Column(name = "TEAM_team_id", nullable = false)),
			@AttributeOverride(name = "gameGameId", column = @Column(name = "GAME_game_id", nullable = false)) })
	public ResultId getId() {
		return this.id;
	}

	public void setId(ResultId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TEAM_team_id", nullable = false, insertable = false, updatable = false)
	@XmlTransient
	public Team getTeam() {
		return this.team;
	}

	public void setTeam(Team team) {
		this.team = team;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "GAME_game_id", nullable = false, insertable = false, updatable = false)
	@XmlTransient
	public Game getGame() {
		return this.game;
	}

	public void setGame(Game game) {
		this.game = game;
	}

	@Column(name = "score", nullable = false)
	public int getScore() {
		return this.score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	@Column(name = "result")
	public Byte getResult() {
		return this.result;
	}

	public void setResult(Byte result) {
		this.result = result;
	}

}
